package com.useeinfo.oa.modules.security.entity;

import com.alibaba.fastjson.JSONObject;
import com.useeinfo.framework.extend.entity.SuperClassEntity;
import com.useeinfo.framework.sugar.tools.CommonSugar;
import com.useeinfo.framework.sugar.tools.DateTimeUtils;
import com.useeinfo.oa.modules.base.entity.Enterprise;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 系统模块（权限所属模块）
 */
@Entity
@Table(name = "system_module")
public class SystemModule extends SuperClassEntity<SystemModule> {

    /**
     * 模块名称
     */
    private String moduleName;
    /**
     * 模块描述
     */
    private String moduleDesc;
    /**
     * 所属应用id
     */
    private Long applicationModuleId;

    @Override
    public JSONObject toJSONObject() {
        JSONObject jsonObject = new JSONObject();

        jsonObject.put("moduleId", CommonSugar.getTypedDefault(getId(), 0L));
        jsonObject.put("createTime", CommonSugar.getTypedDefault(DateTimeUtils.formatDateToStringWithTime(getCreateDate()), ""));
        jsonObject.put("moduleName", CommonSugar.getTypedDefault(getModuleName(), ""));
        return jsonObject;
    }

    public SystemModule() {
    }

    public SystemModule(String moduleName, String moduleDesc, Long applicationModuleId) {
        this.moduleName = moduleName;
        this.moduleDesc = moduleDesc;
        this.applicationModuleId = applicationModuleId;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getModuleDesc() {
        return moduleDesc;
    }

    public void setModuleDesc(String moduleDesc) {
        this.moduleDesc = moduleDesc;
    }

    public Long getApplicationModuleId() {
        return applicationModuleId;
    }

    public void setApplicationModuleId(Long applicationModuleId) {
        this.applicationModuleId = applicationModuleId;
    }
}
